package com.sky.mapper;


import com.github.pagehelper.Page;
import com.sky.anno.AutoFill;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface SetmealMapper {


    @Select("select count(*) from setmeal where category_id=#{id}")
    Integer selectByCategoryID(Long id);

    @AutoFill(OperationType.INSERT)
    void insertOne(Setmeal setmeal);

    ////-2--套餐分页--加入分类名称参数
    Page<SetmealVO> selectPage(SetmealPageQueryDTO setmealPageQueryDTO);

    Integer selectStatusById(List<Long> ids);

    void deleteByIds(List<Long> ids);

    //-4.1--根据id查询套餐
    @Select("Select * from setmeal where id=#{name}")
    Setmeal selectById(Long id);

    //-4.2--修改套餐
    @AutoFill(OperationType.UPDATE)
    void updateSetmeal(Setmeal setmeal);


    ////--2--套餐起售、停售
    @Update("update setmeal set status=#{status} where id=#{id}")
    void updateSetmealByStatus(Integer status, Long id);

    @Select("select * from setmeal where category_id=#{id}")
    List<Setmeal> selectListByCategoryID(Long categoryId);

    Integer countByMap(Map paramMap);
}
